﻿using System;
using System.Collections.Generic;
using System.Text;
using static Asion.Dapper.SqlMapperExtensions;

namespace Asion.Dapper.SqlBuilder
{
    public interface ICustomTableMappingHandle
    {
        public CustomTableMapping GetCustomTableMapping();


        /// <summary>
        /// get column mapping
        /// </summary>
        /// <param name="column"></param>
        /// <returns></returns>
        public CustomColumnMapping GetColumnMapping(string column);

        /// <summary>
        /// get slect column
        /// </summary>
        /// <returns></returns>
        public List<CustomColumnMapping> GetSelectColumn();


        public PropertyIdentity GetIdentity();


        public string GetTableName();
    }


    public class SimpleCustomTableMappingHandle : ICustomTableMappingHandle
    {

        public SimpleCustomTableMappingHandle(CustomTableMapping customTableMapping)
        {
            CustomTableMapping = customTableMapping;
        }

        public CustomTableMapping CustomTableMapping;

        public CustomTableMapping GetCustomTableMapping()
        {
            return CustomTableMapping;
        }

        public CustomColumnMapping GetColumnMapping(string column)
        {
            return CustomTableMapping.GetColumnMapping(column);
        }

        public List<CustomColumnMapping> GetSelectColumn()
        {
            return CustomTableMapping.GetSelectColumnMapping();
        }

        public PropertyIdentity GetIdentity()
        {
            return new PropertyIdentity(CustomTableMapping.Type);
        }

        public string GetTableName()
        {
            return this.CustomTableMapping.TableName;
        }
    }
}

